package com.steven.forum.dao

import com.steven.forum.pojo.Complain
import org.apache.ibatis.annotations.Insert
import org.apache.ibatis.annotations.Select
import org.apache.ibatis.annotations.Update
import org.springframework.stereotype.Repository

@Repository
interface ComplainDao {
    @Insert("insert into user_complain(uid, content, images, fromUid, createTime) VALUE (#{targetUid},#{content},#{images},#{fromUid},#{createTime})")
    fun addComplain(targetUid: Long, content: String, images: String, fromUid: Long, createTime: Long = System.currentTimeMillis()): Int

    @Update("update user_complain set status=true where id=#{id}")
    fun updateComplain(id:Long):Int

    @Select("select *\n" +
            "from user_complain\n" +
            "where createTime < #{lastCreateTime} and status=0\n" +
            "order by createTime\n" +
            "limit 10")
    fun queryComplain(lastCreateTime:Long):List<Complain>
}